// pages/find/find/detail/review.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    judge_info:{},
    remark:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.kuoqi.initPage(this);//基础的数据初始化
    this.setData(options);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //this.reloadUnitBranchs();
    this.getFindDetail();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //获取发现详情
  getFindDetail:function(){
    var ths = this;
    app.kuoqi.getFindDetail(this.data.no,function(data){
      ths.setData({info:data});
      ths.getJudegs();
    });
  },
  
  //在发现详情中启用
  //获取评审的内容信息
  getJudegs:function(){
    var ths = this;
    var find_no = this.data.info.order_no;
    app.kuoqi.ajax({
      url:'/Api/UnitJudges/Judgeinfo',
      type:'post',
      dataType:'json',
      data:{
        find_no:find_no
      },
      success:function(rs){
        if(rs.status==1){
          ths.setData({judge_info:rs.data});
        }else{
          //这个什么都不做
          wx.showModal({
            content:rs.message,
            cancelColor: 'cancelColor',
            showCancel:false,
          })
        }
      }
    });
  },
  
  //反诉被评审驳回
  doDisagreeJudges:function(){
    var ths = this;
    var find_no = this.data.no;
    var id = this.data.judge_info.id;
    wx.showModal({
      content:"确定驳回吗？",
      confirmText:"是",
      cancelText:"否",
      cancelColor: 'cancelColor',
      complete:function(rs){
        if(rs.cancel==true){
          return true;
        }
        app.kuoqi.ajax({
          url:'/Api/UnitJudges/DisagreeJudges',
          type:'post',
          dataType:'json',
          data:{
            id:id,
            remark:ths.data.remark,
          },
          success:function(rs){
            if(rs.status==1){
              wx.navigateBack({
                delta: 0,
              })
            }else{
              //这个什么都不做
              wx.showModal({
                content:rs.message,
                cancelColor: 'cancelColor',
                showCancel:false,
              })
            }
          }
        });
      }
    })
    
  },

  //反诉被评审同意
  doAgreeJudges:function(){
    var ths = this;
    var find_no = this.data.no;
    var id = this.data.judge_info.id;
    wx.showModal({
      content:"确定同意吗？",
      confirmText:"是",
      cancelText:"否",
      cancelColor: 'cancelColor',
      complete:function(rs){
        if(rs.cancel==true){
          return true;
        }
        app.kuoqi.ajax({
          url:'/Api/UnitJudges/AgreeJudges',
          type:'post',
          dataType:'json',
          data:{
            id:id,
            remark:ths.data.remark,
          },
          success:function(rs){
            if(rs.status==1){
              wx.navigateBack({
                delta: 0,
              })
            }else{
              //这个什么都不做
              wx.showModal({
                content:rs.message,
                cancelColor: 'cancelColor',
                showCancel:false,
              })
            }
          }
        });
      }
    });
  },
  inputRemark:function(e){
      this.data.remark = e.detail.value;
  },
  showKqSlider : function(){
      this.KqSlider._show();
  }
})